import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;

public class game extends GameCanvas implements Runnable{
	int x,y,key;
	Image img,back,tile;
	Graphics g;
	TiledLayer backg;
public game()
{
super(false);

}
public void start()
{
	Thread t=new Thread(this);
	t.setPriority(10);
	t.start();
	x=getWidth()/2;
	y=getHeight()/2;
	try {
		img=Image.createImage("small3d.png");
		back=Image.createImage("back.png");
	} catch (Exception e) {
		
		e.printStackTrace();
	}
	
	}
public void run() {
	g=getGraphics();
while(true)
{
	verifyGameState();
	checkUserInput();
	updateGameScreen(getGraphics());
	try {
		Thread.sleep(5);
	} catch (Exception e) {
		e.printStackTrace();
	}
	}

}
private void updateGameScreen(Graphics g) {
	for(int i=0;i<getWidth();i+=back.getWidth())
	{for(int j=0;j<getHeight();j+=back.getHeight())
	{
		g.drawImage(back,i,j,Graphics.HCENTER|Graphics.BOTTOM);
		
	}}
	
g.drawImage(img, x, y, Graphics.HCENTER|Graphics.BOTTOM);
flushGraphics();
}
private void checkUserInput() {
	key=getKeyStates();
	if((key&game.UP_PRESSED)!=0){y--;}
	else if((key&game.LEFT_PRESSED)!=0){x--;}
	else if((key&game.RIGHT_PRESSED)!=0){x++;}
	else if((key&game.DOWN_PRESSED)!=0){y++;}
}
private void verifyGameState() {
	
	
}

}